#! /bin/sh
# Finds LibVLC API mismatch within the CIL bindings
# Copyright 2008 Rémi Denis-Courmont

if test "${srcdir}" = ""; then
	srcdir="$(dirname "$0")"
fi

libvlcsym="${srcdir}/../../../src/libvlc.sym"
if ! test -f "${libvlcsym}"; then
	echo "Cannot find ${libvlcsym}\!" >&2
	exit 77
fi

cat ${srcdir}/../src/*.cs | \
sed -n -e 's,^.*EntryPoint="\([^"]*\)".*$,\1,p' | {
	cat
	# Symbols we do not need:
	echo 'libvlc_exception_raise'
} | \
sort -u | \
diff -u - "${libvlcsym}" | \
grep -ve '^+\(mediacontrol_\|libvlc_playlist_\)' | {
	read line # ---
	read line # +++
	broken=no
	while read line; do
		match="${line#+}"
		if test "${line}" != "${match}"; then
			echo "Unimplemented: $match"
			broken=yes
		fi

		match="${line#-}"
		if test "${line}" != "${match}"; then
			echo "Invalid:       $match"
			broken=yes
		fi
	done
	test "${broken}" = "no"
}
